import {request} from '@/utils/request'
//base url
const BASE_URL = process.env.VUE_APP_API_BASE_URL
const api = {
    file_upload: '/file/upload', //上传文件
    file_import: '/file/import', //上传文件
    download_file: '/file/get', //下载文件
    get_employee_list: '/employee/list',//获取所有员工
    get_organization_list: '/organization/get_organization_list', // 获取所有部门信息
    save_category: '/asset_category/save', //新增分类信息
    update_category: '/asset_category/update', //编辑分类信息
    get_category_list: '/asset_category/list', //获取分类信息
    delete_category: '/asset_category/delete', //删除分类信息
    save_extended_define: '/asset_category/save_extended_define', //新增分类扩展信息
    get_extended_define: '/asset_category/get_extended_define', //获取分类扩展信息
    delete_extended_define: '/asset_category/delete_extended_define', //删除分类扩展信息
    update_extended_define: '/asset_category/update_extended_define', // 修改分类扩展信息
    get_template_list: '/template/list', //获取模板
    save_template: '/template/save',// 保存模板
    update_template: '/template/update', //编辑模板
    delete_template: '/template/delete', // 删除模板
    get_category_type_list: '/asset_category/category_type_list', //获取分类类型
    save_asset: '/asset/save', //新增资产
    get_asset_list: '/asset/list', //获取资产
    delete_asset: '/asset/delete', //资产删除
    update_asset: '/asset/update', //资产修改
    save_extend: '/asset/save_extend', // 资产新增扩展信息
    update_extend: '/asset/update_extend',//资产修改扩展信息
    get_unit_list: '/asset/get_unit_list', //获取资产基础单位
    get_supplier: '/asset/supplier_list', //供应商列表查询
    get_asset_file_list: '/asset/file_list', //获取资产的上传文件列表
    get_organization_profile_list: '/organization/profile/list', //获取公司设置
}

for (const apiKey in api) {
    api[apiKey] = BASE_URL + api[apiKey];
}
export function get_organization_list (parameter) {
    return request( api.get_organization_list,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function get_employee_list (parameter) {
    return request( api.get_employee_list,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function save_category (parameter) {
    return request(
      api.save_category + '?organization_id='+parameter.organization_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function update_category (parameter) {
    return request(
      api.update_category + '?organization_id='+parameter.organization_id + '&asset_category_id=' + parameter.asset_category_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function get_category_list (parameter) {
    return request( api.get_category_list,
      'get',
      parameter,
    )
}
export function delete_category (parameter) {
    return request( api.delete_category,
      'get',
      parameter,
    )
}
export function save_extended_define (parameter) {
    return request(
      api.save_extended_define + '?organization_id='+parameter.organization_id + '&class_id=' + parameter.class_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function delete_extended_define (parameter) {
    return request( api.delete_extended_define + '?organization_id='+parameter.organization_id + '&asset_extend_define_id=' + parameter.asset_extend_define_id,
      'get',
      parameter,
    )
}
export function update_extended_define (parameter) {
    return request(
      api.update_extended_define + '?organization_id='+parameter.organization_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function get_extended_define (parameter) {
    return request( api.get_extended_define,
      'get',
      parameter,
    )
}
export function save_template (parameter) {
    return request(
      api.save_template + '?organization_id='+parameter.organization_id + '&template_type=' + parameter.template_type,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function update_template (parameter) {
    return request(
      api.update_template + '?organization_id='+parameter.organization_id + '&template_type=' + parameter.template_type,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function get_template_list (parameter) {
    return request( api.get_template_list,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function delete_template (parameter) {
    return request( api.delete_template,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function get_category_type_list (parameter) {
    return request(
      api.get_category_type_list,
      'get',
      parameter,
      // { 'Timestamp': parameter }
    )
}
export function file_import (parameter) {
    return request(
      api.file_import + '?file_type=' + parameter.file_type+'&organization_id='+parameter.organization_id+'&dept_id='+parameter.dept_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function get_asset_list (parameter) {
    return request( api.get_asset_list,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function save_asset (parameter) {
    return request(
      api.save_asset + '?organization_id='+parameter.organization_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function update_asset (parameter) {
    return request(
      api.update_asset + '?organization_id='+parameter.organization_id + '&asset_id=' + parameter.asset_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function delete_asset (parameter) {
    return request( api.delete_asset,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function save_extend (parameter) {
    return request(
      api.save_extend + '?organization_id='+parameter.organization_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function update_extend (parameter) {
    return request(
      api.update_extend + '?organization_id='+parameter.organization_id,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function get_unit_list (parameter) {
    return request( api.get_unit_list,
      'get',
      parameter,
      // { headers: parameter.headers }
    )
}
export function get_supplier (parameter) {
    return request( api.get_supplier,
      'get',
      parameter,
      // { 'Timestamp': parameter }
    )
}
export function get_asset_file_list (parameter) {
    return request( api.get_asset_file_list,
      'get',
      parameter,
    )
}
export function file_upload (parameter) {
    return request(
      api.file_upload + '?id='+parameter.id+'&organization_id='+parameter.organization_id+'&type='+parameter.file_type,
      'post',
      parameter.data,
      { headers: parameter.hearders }
    )
}
export function download_file (parameter) {
    return request( api.download_file,
      'get',
      parameter,
      { responseType: 'blob' }
    )
}
export function get_organization_profile_list (parameter) {
    return request(
      api.get_organization_profile_list,
      'get',
      parameter,
      // { 'Timestamp': parameter }
    )
}
